/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FOUNDATION_ABILITY_RUNTIME_CROSS_PLATFORM_INTERFACES_KITS_NATIVE_ABILITY_CJ_ABILITY_H
#define FOUNDATION_ABILITY_RUNTIME_CROSS_PLATFORM_INTERFACES_KITS_NATIVE_ABILITY_CJ_ABILITY_H

#include <memory>
#include "ability.h"
#include "window_stage_impl.h"

namespace Keels {
namespace AbilityRuntime {
class CJRuntime;
namespace Platform {
class CJAbilityObject;
using Want = AAFwk::Want;

class CJAbility : public Ability {
public:
    /**
     * @brief Create a CJAbility instance through the singleton pattern
     * @param runtime The runtime of the ability
     * @return Returns the JsUIAbility Instance point
     */
    static std::shared_ptr<Ability> Create(const std::unique_ptr<Runtime>& runtime);

    explicit CJAbility(CJRuntime& cjRuntime);
    ~CJAbility() override = default;

    void Init(const std::shared_ptr<AppExecFwk::AbilityInfo>& abilityInfo) override;
    void OnCreate(const Want& want) override;
    void OnForeground(const Want& want) override;
    void OnWindowStageCreated() override;
    void OnWindowStageDestroy() override;
    void OnDestroy() override;

private:
    CJRuntime& cjRuntime_;
    std::shared_ptr<CJAbilityObject> cjAbilityObj_;
    sptr<Keels::Rosen::CJWindowStageImpl> cjWindowStage_;
};
} // namespace Platform
} // namespace AbilityRuntime
} // namespace Keels
#endif // FOUNDATION_ABILITY_RUNTIME_CROSS_PLATFORM_INTERFACES_KITS_NATIVE_ABILITY_CJ_ABILITY_H
